/****************************************************************
 *
 * Project: Handle ARM M4 STM32F407VG In 2 Weeks
 * 
 ****************************************************************/

/****************************************************************
 *
 *	Module		: "header file" myGpio.c
 *  Tool		: KeilC ARM 4.22a
 *	Chip		: STM32F407VG
 * 	History		: 9/12/2011
 *	Description	: Day 7
				  + My library to use IOs
				  + Reference to header file "myGpio.h"
 *				
 *	Author		: Dang Anh Tung			
 *	Description	: www.payitforward.edu.vn
 *				
 *
 ****************************************************************/

 
 /****************************************************************
 * 							IMPORT
 ****************************************************************/
 #include "myGpio.h"

/*****************************************************************
* 							DEFINE
******************************************************************/

 /****************************************************************
 * 							GLOBAL
 ****************************************************************/


 /****************************************************************
 * 						   FUNCTIONS
 ****************************************************************/


 /****************************************************************
** Function name:	    myGpioInit
**
** Descriptions:	    	
**
** parameters:			None
** Returned value:		None
** 
*****************************************************************/
 void myGpioInit(void)
 {
	GPIO_InitTypeDef  GPIO_InitStructure;
	
	/*
	*	Configure User Button at PA0 
	*	PA0 = 1 when button is pressed 
	*/
	
	// GPIOA Periph clock enable
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
	// Configure PA0 = { Input, Speed_100Mhz, No pull}
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIOA, &GPIO_InitStructure);
	
	/*
	*	Configure Leds at PD12, PD13, PD14, PD15
	*	Led is turned on when ouput is high level
	*/

	// GPIOD Periph clock enable 
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
	// Configure PDi = {Ouput, Speed-100mhz, push-pull, no pull}
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIOD, &GPIO_InitStructure);
 }

/****************************************************************
 * END OF standard form.c
 ****************************************************************/
